
<template>
    <el-form :model="form" label-width="120px">
      <el-form-item label="Username">
        <el-input v-model="form.username"></el-input>
      </el-form-item>
      <el-form-item label="Password">
        <el-input type="password" v-model="form.password"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="register">Register</el-button>
      </el-form-item>
    </el-form>
  </template>
  
  <script>
  import axios from 'axios'
  
  export default {
    data() {
      return {
        form: {
          username: '',
          password: '',
        },
      }
    },
    methods: {
      async register() {
        try {
          await axios.post('/api/register/', this.form)
          this.$router.push('/login')
        } catch (error) {
          console.error(error)
        }
      },
    },
  }
  </script>